package com.tianhui.consignortwofei.other.auth.recognition.process;

import android.text.TextUtils;

import com.fgs.common.utils.ToastUtil;
import com.tianhui.consignortwofei.mvp.model.enty.RecognitionInfo;
import com.tianhui.consignortwofei.mvp.model.enty.SelectPhotoInfo;
import com.tianhui.consignortwofei.mvp.model.enty.ocrResult.roadTransport.RoadTransportInfo;
import com.tianhui.consignortwofei.mvp.model.enty.ocrResult.roadTransport.RoadTransportResult;
import com.tianhui.consignortwofei.other.auth.inte.ProcessCallback;
import com.tianhui.consignortwofei.other.auth.recognition.recognitionResultProcess.VehicleRoadOcrResultProcess;

/**
 * @author fgs
 * @date 2021/5/13
 * @description
 **/
public class VehicleRoadRecognitionProcess implements IRecognitionProcess<RoadTransportResult, RoadTransportInfo> {

    @Override
    public void recognitionProcess(RecognitionInfo<RoadTransportResult> recognitionInfo, SelectPhotoInfo selectPhotoInfo, ProcessCallback<RoadTransportInfo> processCallback) {

        RoadTransportResult roadTransportResult = recognitionInfo.info;

        if (roadTransportResult != null) {
            VehicleRoadOcrResultProcess resultProcess = new VehicleRoadOcrResultProcess();
            RoadTransportInfo roadTransportInfo = resultProcess.getVehicleRoadInfo(roadTransportResult);
            if (roadTransportInfo == null) {
                roadTransportInfo = new RoadTransportInfo();
            } else {
                if (!TextUtils.isEmpty(roadTransportInfo.vehicle_number) && roadTransportInfo.vehicle_number.contains("挂")) {
                    ToastUtil.showShortToast("请上传车头的道路运输证");
                    processCallback.processFailed();
                    return;
                }
            }
            roadTransportInfo.path = selectPhotoInfo.filePath;
            processCallback.processSuccess(roadTransportInfo);
        } else {
//            processCallback.processFailed();
            processCallback.processSuccess(null);
        }

    }

}
